<?php
/**
 * @Author: Kendy
 * @Date:   2019-11-14 16:50:15
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2019-11-15 14:46:45
 */
namespace app\api\model; 
use think\Model;
use think\Db;  
use app\api\model\Collect;
use app\common\model\Settlements;
class TourManages extends Model
{ 
    /**
     * [getGuideManInfo 获取导游管理的页面]
     * @Author   kendy
     * @DateTime 2019-11-15T09:10:39+0800
     * @param    [type]                   $guideId [导游id]
     * @return   [type]                            [导游信息]
     */
    public function getGuideManInfo($guideId)
    {
        $guideInfo = Db::name('guide')
         ->field('guide_id,guide_head,guide_rank,guide_tag,name,sales_volume')
         ->where(['guide_id'=>$guideId,'is_del'=>0,'is_pass'=>1])
         ->find();  
         $guideInfo['guide_tag'] = explode(',', $guideInfo['guide_tag']);
        //查看该导游信息是否有效
        if(empty($guideInfo))
        	 return apiReturn('400','无效的导游信息',0);
         $collect = new Collect();
        //查看导游的被收藏数
        $guideInfo['collection'] = $collect->getProCollectionnNum($guideId,6);
        $set = new Settlements();
        //查看累计金额（已经结算的）
        $guideInfo['total_money'] = $set->getSettledMoney($guideId,4);
        //查看当月未结算的
         $guideInfo['unsettled_money'] = $set->getNoSettleMoney($guideId,4);
         //查看业务订单数
         $guideInfo['business_count'] = Db::name('guide_order')
         ->where(['is_del'=>0,'order_status'=>1,'guide_id'=>$guideId])
         ->count();  
         return apiReturn('200','成功',$guideInfo);
    }

    /**
     * [getGuideInfo 获取导游的信息]
     * @Author   kendy
     * @DateTime 2019-11-15T14:39:46+0800
     * @param    [type]                   $guideId [description]
     * @return   [type]                            [description]
     */
   public function getGuideInfo($guideId)
   {

      $guideInfo = Db::name('guide')
       ->field('guide_id,name,cardid,guide_tel,guide_card,examine_time,guide_tag,guide_content')
       ->where(['guide_id'=>$guideId,'is_del'=>0,'is_pass'=>1])
       ->find();  
       if(empty($guideInfo))
       	 return apiReturn('400','无效的导游信息',0);
       if(!empty($guideInfo))
       {
       	 $guideInfo['guide_tag'] = explode(',', $guideInfo['guide_tag']);
       }

    return apiReturn('200','成功',$guideInfo);
   }

}
